package com.dshore.messagecenter.service.statistics.impl;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dshore.messagecenter.dao.statistics.MemoryUsageDao;
import com.dshore.messagecenter.service.statistics.MemoryUsageService;
import com.dshore.messagecenter.util.GetNowTimeListOFSeven;
@Service
public class MemoryUsageServiceImpl implements MemoryUsageService {
	@Autowired
	MemoryUsageDao  muDao;
	


	// 获取各个主题队列的内存占用
	@Override
	public List<List<Object>>getEveryTopicMemory() {
		GetNowTimeListOFSeven gntls=new GetNowTimeListOFSeven();
		List<String>list1=gntls.getKpiTimes();
		String time=list1.get(list1.size()-1);
		
		Date d=new Date();
		DateFormat df=new SimpleDateFormat("yyyy-MM-dd ");
		String riqi=df.format(d);  //2018/08/01 
		
		String rq=riqi+""+time;//2018-08-28 12:05
		
		 List<Map<String, Object>> list=muDao.getEveryTopicMemory(rq);
		 List<Object> obvalue=new ArrayList<>();
		 List<Object> obname=new ArrayList<>();
		 for (Map<String, Object> map : list) {
			Object value=map.get("sum");
			Object topicname=map.get("topicname");
			obvalue.add(value);
			obname.add(topicname);
		}
		List<List<Object>>li=new ArrayList<>();
		li.add(obname);
		li.add(obvalue);
		return li;
	}
	 
}
